//go through all the models and output MAE and RMSE

clear all
set more off

use ${dat}\hsv_samp.dta  , clear


*generate the net of tax marginal rate
gen mnotr=1-(mtrate/100)

*generate the residual income elasticity
gen rie=mnotr*(y_gross/y_net)

*drop outliers
drop if rie>3 


sort y_gross 
xtile grp=y_gross, nq(100)

sum y_gross if grp==10
sum y_gross if grp==100

collapse (mean) rie y_gross, by(grp) 

sum rie
gen rmean=r(mean)


 
scatter rie grp, msymbol(+) msize(small)  || lfit rmean grp, lc(black) ///
 , ytitle(Residual Income Elasticity) xtitle(Gross Income Quantile) scheme(s1mono) name(binned, replace) legend(off)  xlabel(, labsize(small))  ylabel(,labsize(small))
 graph export ${res}binned_rie.png, replace
